<?php
use yii\helpers\Url;
use yii\bootstrap\ActiveForm;
use yii\bootstrap\Html;
?>
<div class="avatar-view" >
    <img  id="pre_avatar" src="<?= $this->context->imageUrl?>" alt="Avatar">
</div>

<script>
    var def_pic = $('#'+target_tip).val();
    var def_pic1 = '<?= $this->context->imageUrl?>';
    if(def_pic==""){
        $('#pre_avatar').attr('src',def_pic1);
    }else{
        $('#pre_avatar').attr('src',""+def_pic);
    }

    $(document).on("click", "#pre_avatar", function() {
        $(".avatar-view").click();
    });

</script>